package com.campus.help.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 学生类型枚举
 *
 * @author campus-help
 * @since 2025-09-18
 */
@Getter
@AllArgsConstructor
public enum StudentType {

    /**
     * 本科生
     */
    UNDERGRADUATE("undergraduate", "本科生"),

    /**
     * 研究生
     */
    GRADUATE("graduate", "研究生"),

    /**
     * 博士生
     */
    PHD("phd", "博士生");

    /**
     * 类型码
     */
    private final String code;

    /**
     * 类型描述
     */
    private final String description;

    /**
     * 根据类型码获取枚举
     */
    public static StudentType fromCode(String code) {
        for (StudentType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown student type code: " + code);
    }
}
